package com.squirrel.common.controller;

import com.squirrel.common.annotation.AuthToken;
import com.squirrel.common.param.userVideo.EvaluateParam;
import com.squirrel.common.param.video.PageParam;
import com.squirrel.common.response.ResponseResult;
import com.squirrel.common.response.ResponseResultUtils;
import com.squirrel.common.response.page.PageResult;
import com.squirrel.common.service.UserVideoService;
import com.squirrel.common.vo.userVideo.HistoryVO;
import com.squirrel.common.vo.userVideo.UserVideoInfoVO;
import com.squirrel.common.vo.video.VideoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * UserVideoController 用户视频控制器
 * </p>
 *
 * @author 关远键
 * @since 2021/11/11 16:06
 */
@RestController
@RequestMapping("/api/user-video")
@Api(tags = "用户视频控制器")
public class UserVideoController {

    @Autowired
    private UserVideoService uvService;

    @GetMapping("/getByVideoId/{videoId}")
    @ApiOperation("喜欢数、收藏数、点赞数、松鼠评分")
    public ResponseResult<UserVideoInfoVO> getByVideoId(@PathVariable("videoId") Integer videoId) {
        UserVideoInfoVO vo = uvService.getByVideoId(videoId);
        return ResponseResultUtils.success(vo);
    }

    @PostMapping("/insert")
    @ApiOperation("松鼠评价")
    @AuthToken
    public ResponseResult<Integer> insert(EvaluateParam param) {
        return ResponseResultUtils.success(uvService.insert(param));
    }

    @GetMapping("/getCollect/{userId}")
    @ApiOperation("收藏列表")
    @AuthToken
    public ResponseResult<PageResult<VideoVO>> getCollect(@PathVariable("userId") Integer userId, PageParam pageParam) {
        return ResponseResultUtils.success(uvService.getCollect(userId, pageParam));
    }

    @GetMapping("/getHistory/{userId}")
    @ApiOperation("观看历史")
    @AuthToken
    public ResponseResult<List<HistoryVO>> getHistory(@PathVariable("userId") Integer userId) {
        return ResponseResultUtils.success(uvService.getHistory(userId));
    }

}
